<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c"%>
<%
	String path = request.getContextPath();
%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>账户 新增</title>
<jsp:include page="../../import.jsp" flush="true"/>

</head>
<body>
<script>
    $(function() {
        var _prjTypCdListJSON = ${ctrlList};
        $("#cityCodeNm").ligerComboBox({ isShowCheckBox: true,isMultiSelect: true,
            data: _prjTypCdListJSON,
            valueField: 'cityCode',
            textField: 'cityName'
        });

        var crPdList = ${crPdList};
        $("#crPdOpt").ligerComboBox({ isShowCheckBox: true,isMultiSelect: true,
            data: crPdList,
            valueField: 'crPd',
            textField: 'crPdOpt'
        });
    });
</script>
		<form id="mcrCrTypClose_form">
            <div class="fieldset1 tabel_col tabel_col_s clearFix noBorder">
                <div class="fieldBox col_50">
                    <div class="label">客户类型</div>
                    <div class="field">
                        <select name="cstTypeCd" id="cstTypeCd">
                            <option value="0">内部</option>
                            <option value="1">外部</option>
                            <option value="2">物流</option>
                            <option value="3">首付贷</option>
                        </select>
                    </div>
                </div>
                <div class="fieldBox col_50">
                    <div class="label">贷款类型</div>
                    <div class="field">
                        <select name="crTypCd" id="crTypCd">
                            <option value="FQHK">分期还款</option>
                            <option value="SJSH">随借随还</option>
                        </select>
                    </div>
                </div>

                <div class="fieldBox col_50">
                    <div class="label">授信等级</div>
                    <div class="field">
                        <select name="crLvlCd" id="crLvlCd">
                            <option value="1111">--全部--</option>
                        </select>
                    </div>
                </div>

                <%--<div class="fieldBox col_50" >
                    <div class="label">开放城市</div>
                    <select multiple="true" name="cogCondition" style="width:100%;">
                        <c:forEach var="mate" items="${fns:getDictList('rdqk')}">
                            <option <c:if test="${fn:contains(projectRecommend.cogCondition,mate.value ) }">selected="selected"</c:if>  name="cogCondition" value="${mate.value }"/>${mate.label}
                        </c:forEach>
                    </select>
                </div>--%>
                <div class="fieldBox col_50" >
                    <div class="label">开放城市</div>
                    <div class="field">
                        <input type="text"  name="cityCodeNm" id="cityCodeNm"  class="ui-textbox" validate="{required:true, maxlength:500}">
                        <input type="hidden" name="cityCode" id="cityCode" data-ligerid="cityCodeNm" value="" >
                    </div>
                </div>

                <div class="fieldBox col_50" >
                    <div class="label">期数</div>
                    <div class="field">
                        <input type="text"  name="crPdOpt" id="crPdOpt"  class="ui-textbox" validate="{required:true, maxlength:500}">
                        <input type="hidden" name="crPd" id="crPd" data-ligerid="crPdOpt" value="" >
                    </div>
                </div>
                <%--<div class="fieldBox col_50">
                    <div class="label">城市</div>
                    <div class="field">
                        <select name="cityCode" id="cityCode">
                            <option value = "1111">全部</option>
                            <c:forEach items="${ctrlList }" var="ct">
                                <option value="${ct.cityCode }">${ct.cityName }</option>
                            </c:forEach>
                        </select>
                    </div>
                </div>--%>

                <div class="fieldBox col_50">
                    <div class="label">是否启用</div>
                    <div class="field">
                        <select name="isValid" id="isValid">
                            <option value="1">是</option>
                            <option value="0">否</option>
                        </select>
                    </div>
                </div>

                <!-- hide data -->
		        <div class="fieldBox col_100" style="display:none;">
		          <div class="field">
		              <input name="dataId" id="dataId" type="text" class="ui-textbox" value="${id}">
		          </div>
		        </div>
            </div>
        </form>
	<script>
		$(function() {
		   $("#mcrCrTypClose_form").ligerForm({
                validate: true
           });
            initData();
		});


		//定义父级调用事件
		frameElement.dialog.onOk = function () {
			save();
		}
		
		frameElement.dialog.onCancel = function () {
			frameElement.dialog.close();
		}
		
		//保存
		function save(){
			var ligerForm = liger.get("mcrCrTypClose_form");
            if (!ligerForm.valid()) {
                UIUtils.alertWarning("有验证信息未通过!");
                return; //验证不通过，不执行以下代码
            }
            var data = ligerForm.getData();
            var dataId = $("#dataId").val();
            var url = '<%=path%>/mcr/mcrCrTypClose/add.do';
            if(StringUtils.isNotEmpty(dataId)){
            	url = '<%=path%>/mcr/mcrCrTypClose/modify.do';
            	data["id"]= dataId;
            }
            AjaxUtils.ajaxPost(url, data, addCallback);
		}
		
		
		//新增回调
		function addCallback(msg){
			if(msg.success == 1){
				 parent.grid.reload();
				 //parent.$.ligerDialog.SQalert({content:'提示内容', SQ_type: "success"});
				 UIUtils.alertSuccess("操作成功!");
				 frameElement.dialog.close();
			 }else{
				 UIUtils.alertError(msg.info);
			 }
		}
		
		//修改初始化数据
		function initData(){
			var dataId = $("#dataId").val();
	    	if(StringUtils.isEmpty(dataId))return;
	    	var _url = '<%=path%>/mcr/mcrCrTypClose/getById.do';
	    	AjaxUtils.ajaxGet(_url, {id:dataId}, initCallback);
    	}
		
		//初始化回调
		function initCallback(msg){
			if(msg.success == 1){
				 setData(msg.data);//设置数据
			 }else{
				 UIUtils.alertError(msg.info);
			 }
		}
		
		//修改时候设置页面数据
	    function setData(data){
	    	var form = new liger.get("mcrCrTypClose_form");
	    	form.setData({
                cstTypeCd:data.cstTypeCd,
                crTypCd:data.crTypCd,
                crPd:data.crPd,
                crLvlCd:data.crLvlCd,
                isValid:data.isValid,
                cityCode:data.cityCode,
                cityCodeNm:data.cityCode,
                crPd:data.crPd,
                crPdOpt:data.crPdOpt,
                sLoanNum:data.sLoanNum,
                vehicleCrpd:data.vehicleCrpd,
                isReduction:data.isReduction,
                loanRatePct:data.loanRatePct
	    	});
		};
	</script>

</body>
</html>